package com.test03_类与对象;

/**
 * static关键字
 */
public class YootkDemo_07 {

    public static void main(String[] args) {
        Book7.setPub("李兴华编程训练营出版社");
        Book7 bookA = new Book7("Java从入门到项目实战", "李兴华", 99.8);
        Book7 bookB = new Book7("Spring开发实战", "李兴华", 69.8);
        System.out.println(bookA.getInfo());
        System.out.println(bookB.getInfo());
        System.out.println("对象个数：" + Book7.getCount());
    }
}

/**
 * 图书类
 */
class Book7 {
    private static int count = 0;   // 对象计数统计
    private static String pub = "沐言科技出版社";  // 出版社
    private String title;
    private String author;
    private double price;

    public Book7() {
        this.count++;
    }

    public Book7(String title, String author, double price) {
        this.count++;
        this.title = title;
        this.author = author;
        this.price = price;
    }

    public static int getCount() {
        return count;
    }

    public static String getPub() {
        return pub;
    }

    public static void setPub(String paramPub) {
        pub = paramPub;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getInfo() {
        return "【图书】名称：" + this.title + "、作者：" + this.author + "、价格：" + this.price + "、出版社：" + this.pub;
    }
}
